package com.example.performance.jol.official;

import org.openjdk.jol.info.ClassLayout;
import org.openjdk.jol.vm.VM;

/**
 * @author Aleksey Shipilev
 */
@SuppressWarnings({"java:S101", "java:S106"})
public class JOLSample_17_ArrayLength {

    /*
     * The example for array length.
     *
     * Array length is not the part of array type, so VMs need another
     * slot in header to store the array length. This can be demonstrated
     * by this example.
     */

    public static void main(String[] args) {
        System.out.println(VM.current().details());

        for (int c = 0; c < 8; c++) {
            System.out.printf("**** int[%d]", c);
            System.out.println(ClassLayout.parseInstance(new int[c]).toPrintable());
        }
    }

}
